<?php
/**
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt or that can be found at 
 * http://code.google.com/p/billboardce/wiki/License.
 *
 * @package    Ot_Validate_UserId
 * @category   Library
 * @license    http://code.google.com/p/billboardce/wiki/License New BSD License
 * @version    SVN: $Id: $
 */

/**
 * validates an NCSU unity ID
 *
 * @package    Ot_Validate_UserId
 * @category   Library
 */
class Ot_Validate_UserId implements Zend_Validate_Interface
{
    /**
     * error messages
     *
     * @var unknown_type
     */
    protected $_messages = array();

    /**
     * checks if value is valid
     *
     * @param mixed $value
     * @return boolean
     */
    public function isValid($value)
    {
        $unityId = preg_match('/^[a-z]{1}[a-z0-9]{2,7}$/', $value);

        if (!$unityId) {
            $this->_messages[] = "User ID is not a valid unity ID.";
            return false;
        }

        return true;
    }

    /**
     * gets error messages
     *
     * @return array
     */
    public function getMessages()
    {
        return $this->_messages;
    }
    /**
     * gets error messages
     *
     * @return array
     */
    public function getErrors()
    {
        return $this->_messages;
    }
}